There’s been recent suggestion that more dams should be built to safegaurd against future droughts. Setting aside the question of where a new dam would be built (most appropriate locations have been utilised already), the thing that often seems to be forgotten is that most of our dams are currently storing more air than water. So how many dams have we built in Australia? Here’s a timline in R.

library(tidyverse)
## ── Attaching packages ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse 1.2.1 ──
## ✔ ggplot2 3.2.1           ✔ purrr   0.3.2      
## ✔ tibble  2.1.3           ✔ dplyr   0.8.3      
## ✔ tidyr   0.8.99.9000     ✔ stringr 1.4.0      
## ✔ readr   1.3.1           ✔ forcats 0.4.0
## Warning: package 'ggplot2' was built under R version 3.5.2
## Warning: package 'tibble' was built under R version 3.5.2
## Warning: package 'purrr' was built under R version 3.5.2
## Warning: package 'dplyr' was built under R version 3.5.2
## Warning: package 'stringr' was built under R version 3.5.2
## Warning: package 'forcats' was built under R version 3.5.2
## ── Conflicts ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(sf)
## Warning: package 'sf' was built under R version 3.5.2
## Linking to GEOS 3.6.1, GDAL 2.1.3, PROJ 4.9.3
library(gganimate)
## Warning: package 'gganimate' was built under R version 3.5.2
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following object is masked from 'package:base':
## 
##     date
if(!requireNamespace("devtools")) install.packages("devtools")
## Loading required namespace: devtools
devtools::install_github("dkahle/ggmap", force=TRUE)
## Downloading GitHub repo dkahle/ggmap@master
## 
##   
   checking for file ‘/private/var/folders/df/mcs85y1s5gg5jkk_hy02xljc0000gp/T/RtmpHRe7ML/remotes12c153c15038/dkahle-ggmap-c2c7f64/DESCRIPTION’ ...
  
✔  checking for file ‘/private/var/folders/df/mcs85y1s5gg5jkk_hy02xljc0000gp/T/RtmpHRe7ML/remotes12c153c15038/dkahle-ggmap-c2c7f64/DESCRIPTION’
## 
  
─  preparing ‘ggmap’:
## 
  
   checking DESCRIPTION meta-information ...
  
✔  checking DESCRIPTION meta-information
## 
  
─  checking for LF line-endings in source and make files and shell scripts
## 
  
─  checking for empty or unneeded directories
##    Removed empty directory ‘ggmap/.github’
## 
  
─  looking to see if a ‘data/datalist’ file should be added
## 
  
─  building ‘ggmap_3.0.0.901.tar.gz’ (653ms)
## 
  
   
## 
library(ggmap)
## Google's Terms of Service: https://cloud.google.com/maps-platform/terms/.
## Please cite ggmap if you use it! See citation("ggmap") for details.
dams <-  readxl::read_excel("Dams-Australia-2010-v1.xls", sheet = "Australia") %>%
  janitor::clean_names() %>% slice(-c(1:2)) %>% unite("use", contains("purpose"), sep = ", ")
## New names:
## * `` -> ...1
## * `` -> ...4
## * `` -> ...8
## * DAM -> DAM...11
## * DAM -> DAM...12
## * … and 5 more problems
dams <- read_sf("kx-australian-dams-and-water-storages-SHP/australian-dams-and-water-storages.shp")
dams <- dams %>% mutate(DAM_DATE = ymd(DAM_DATE, truncated = 2)) %>% filter(!is.na(DAM_DATE))
## Warning: 1 failed to parse.
dams <- cbind(dams, sf::st_coordinates(dams))
dams <- dams %>% arrange(DAM_DATE) %>%
  mutate(n_dams=row_number())

all_years <- data.frame(DAM_DATE = seq(from=min(dams$DAM_DATE, na.rm=TRUE), to=as.Date(cut(Sys.Date(), "year")), by="year"))
dams <- left_join(all_years, dams, by="DAM_DATE") %>% arrange(DAM_DATE) %>%
  mutate(Year = year(DAM_DATE)) %>% fill(DAM_DATE:n_dams)

register_google(key="AIzaSyDZUXiRXRLl0qTdJSus6Cg_hGFdu5wZOio")

library(ggmap)
oz_map <- get_map(location = 'Australia', zoom = 4, source = 'google', maptype="satellite")
## Source : https://maps.googleapis.com/maps/api/staticmap?center=Australia&zoom=4&size=640x640&scale=2&maptype=satellite&language=en-EN&key=xxx
## Source : https://maps.googleapis.com/maps/api/geocode/json?address=Australia&key=xxx
n_years <- nrow(distinct(dams, Year))


dams_in_time <-
  ggmap(oz_map) +
  geom_point(data = dams, aes(x=X, y=Y, group = seq_along(Year), size = CAPACITY), colour = "red", alpha=0.5) +
  transition_reveal(Year, keep_last = TRUE) +
  labs(title = "Large Dams in Australia", 
       subtitle = 'Year: {frame_along},  Number of Dams: {dams$n_dams[dams$Year == frame_along][1]}',
       size = expression("Capacity (10"^3*"m"^3*")"))

dams_in_time <- animate(plot = dams_in_time, 
                        nframes = n_years, 
                        fps=2, 
                        device="png", 
                        height = 500, 
                        width =500, 
                        )



anim_save("oz_dams_in_time.gif")
dams_in_time